<?php

class Ead_AcessopaginasController extends App_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction() {
        Zend_Loader::loadClass('datetools','library');
        
        $where = 'ACE_ID > 0';//'CUR_STA = "1"';
        
        $search = $this->_getParam('inp-search', '');
        $this->view->search = $search;
        if(strlen($search) > 2){
            $where .= ' AND ACE_CTL like "%'.$search.'%"';
        }
        
        $data = $this->_getParam('data', '');
        if(strlen($data) > 1){
            $where .= ' AND ACE_DATHOR like "'.Datetools::dma_amd($data).'%"';
        }
        
        $tpo = $this->_getParam('tpo', '1');
        if(strlen($tpo) > 0){
            $where .= ' AND ACE_TPO = '.$tpo;
        }
        
        $obj = new Ead_Model_DbTable_Acessopaginas();
        //$result = $obj->fetchAll($where);
        $result = $obj->fetchAll($obj->select()->where($where)->order(array('ACE_DATHOR DESC')));
        $this->view->result = $this->paginacao($result);
        /*
        $db = Zend_Db_Table::getDefaultAdapter();
       
        $row = $db->select()->from('ACESSO_PAGINAS')->query()->fetchAll();
        print_r($row);
        
        $this->view->result = $row;
        */
    }
    
    
}

